#include<stdio.h>
#include<stdlib.h>

struct CANDY
{
	float price;
	int num;
};

int cmp(const void *a,const void *b);
int main(void)
{
	int buy,n,j=0;
	float sum=0;
	scanf("%d\n%d",&buy,&n);
	struct CANDY shop[n];
	for(int i=0;i<n;i++)
	{
		scanf("%f %d",&shop[i].price,&shop[i].num);
	}
	
	qsort(shop,n,sizeof(struct CANDY),cmp);
	
	while(buy>shop[j].num)
	{
		sum+=(shop[j].num*shop[j].price);
		buy-=shop[j].num;
		j++;
	}
	sum+=(buy*shop[j].price);
	printf("%.2f",sum);
	
	return 0;
}
int cmp(const void *a,const void *b)
{
	struct CANDY *s1=(struct CANDY *)a;
	struct CANDY *s2=(struct CANDY *)b;
	if((s1->price)-(s2->price)>0)
	{
		return 1;
	}
	else if((s1->price)-(s2->price)<0)
	{
		return -1;
	}
	else
	{
		return 0;
	}
}
